import { getSearchGoods } from '@/api'

export default {
  namespaced: true,
  state: {
    searchInfo: {}
  },
  mutations: {
    SET_SEARCH_INFO (state, search) {
      state.searchInfo = search
    }
  },
  actions: {
    async getSearchInfo ({ commit }, query) {
      const res = await getSearchGoods(query)
      commit('SET_SEARCH_INFO', res)
    }
  },
  getters: {
    // 商品列表
    goodsList: state => state.searchInfo.goodsList,
    // 品牌列表
    trademarkList: state => state.searchInfo.trademarkList,
    // 属性列表
    attrsList: state => state.searchInfo.attrsList,
    // 总数量
    total: state => state.searchInfo.total
  }
}
